package com.pg.agent.engine.client.vo;

import com.pg.base.enums.ResultEnum;
import lombok.Data;

import javax.validation.constraints.NotNull;

/**
 * 类名
 *
 * @author huhuaping
 * @date 2024/1/12 9:41
 */
@Data
public class SOPResultVO<T> {
    private @NotNull int errCode = 0;
    private @NotNull String errMessage = "success";
    private @NotNull String dataId = "";
    private T data;
    private String content;
    private Boolean finish;

    private Integer first;

    public SOPResultVO() {
    }

    public static SOPResultVO instance() {
        SOPResultVO vo = new SOPResultVO();
        return vo;
    }

    public static SOPResultVO instance(String content, Boolean finish, String dataId, Object data) {

        SOPResultVO vo = new SOPResultVO();
        vo.setData(data);
        vo.setContent(content);
        vo.setFinish(finish);
        vo.setDataId(dataId);
        return vo;
    }

    public static SOPResultVO instance(ResultEnum result, String dataId) {
        SOPResultVO vo = new SOPResultVO();
        vo.setErrCode(result.getCode());
        vo.setErrMessage(result.getMsg());
        vo.setFinish(true);
        vo.setDataId(dataId);
        return vo;
    }

    public static SOPResultVO instance(int code, String msg, Boolean finish, String dataId) {
        SOPResultVO vo = new SOPResultVO();
        vo.setErrCode(code);
        vo.setErrMessage(msg);
        vo.setFinish(finish);
        vo.setDataId(dataId);
        return vo;
    }


    public void setResult(ResultEnum result) {
        this.errCode = result.getCode();
        this.errMessage = result.getMsg();
    }

    public void setResult(int code, String msg) {
        this.errCode = code;
        this.errMessage = msg;
    }


}
